package org.amicofragile.test.springintegration.routing;

import java.text.MessageFormat;

import org.amicofragile.test.springintegration.dto.Person;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.annotation.Router;

public class FamilyRouting
{
	private static final Log LOG = LogFactory.getLog(FamilyRouting.class);
	@Router
	public String manageDestination(final Person person)
	{
		String outputChannel ="foreignChannel"; 
		if(person.getSurname().toLowerCase().trim().equals("martinelli"))
		{
			outputChannel = "familyChannel";
		}
		if(LOG.isInfoEnabled())
		{
			LOG.info(MessageFormat.format("Routing {0} to channel {1}", person.toString(), outputChannel));
		}
		return outputChannel;
	}
}
